/*
 * @Author: White
 * @description: vuex
 * @LastEditTime: 2021-08-19 17:20:14
 */

import { createStore } from 'vuex'

export default createStore({
  state: {
    todos: [] as string[],
    dones: [] as string[],
    deletes: [] as string[],
  },
  mutations: {
    // 添加事项
    add (state, value: string) {
      state.todos.push(value)
    },
    // 删除事项
    delete (state, index: number) {
      const item = state.todos[index]
      state.todos.splice(index, 1)
      state.deletes.push(item)
    },
    // 完成该事项
    check (state, index: number) {
      const item = state.todos[index]
      state.todos.splice(index, 1)
      state.dones.push(item)
    }
  },
  actions: {
  },
  modules: {
  }
})
